using System;
using System.Windows;
using System.Data;
using System.Xml;
using System.Configuration;
using System.IO;
using System.Reflection;

namespace SkinMe
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>

    public partial class App : System.Windows.Application
    {
        public App()
        {

            //this.Resources.MergedDictionaries.Add( GetFromName("DemoResource.xaml") );
            
            
            foreach (string arg in Environment.GetCommandLineArgs())
            {
                if (File.Exists(arg) && arg.EndsWith(".xaml",StringComparison.OrdinalIgnoreCase))
                {
                    try
                    {
                        this.Resources.MergedDictionaries.Add(GetFromName(arg));
                    }
                    catch
                    { 
                      // Eating exception
                    }
                }
            }
        }

        private ResourceDictionary GetFromName(string name)
        {
            ResourceDictionary dict = new ResourceDictionary();
            dict.Source = new Uri("file://" +
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName) + "/" + name);
            return dict;            
        }
    }
}